#define  _ACCProcessor_GLOBAL_
#include "config.h"

void powerOnStep(void)
{
	if (eACCOff == ACCInfo.ACCPowerStep)//Power On
	{
		ACCInfo.ACCPowerStep = eACCPowerOnControl;
		ACCInfo.ACCPowerStepTime = GetTickCount();
	}
	else if (eACCPowerOnControl == ACCInfo.ACCPowerStep)
	{
		
		ACCInfo.ACCPowerStep = eACCPowerOnDelay;
		ACCInfo.ACCPowerStepTime = GetTickCount();
	}
	else if (eACCPowerOnDelay == ACCInfo.ACCPowerStep)
	{
		if (GetTickCount() - ACCInfo.ACCPowerStepTime >= 100*T_1MS)
		{
			NAVIBOARD_RESET_OFF;
			ACCInfo.ACCPowerStep = eACCPowerOn;
			ACCInfo.ACCPowerStepTime = GetTickCount();
		}
	}
}

void testLEDBlink(void)
{
	if (ACCInfo.LEDBlinkOn)
	{
		TEST_LED_ON;
	}
	else
	{
		TEST_LED_OFF;
	}
	ACCInfo.LEDBlinkOn = !ACCInfo.LEDBlinkOn;
}

void ACCFreeIdleProc(void)
{
	powerOnStep();

	if (GetTickCount() - ACCInfo.LEDBlinkTime >= T_1MS*200)
	{
		ACCInfo.LEDBlinkTime += T_1MS*200;

		testLEDBlink();
	}
}

void ACCInit(void)
{
	SELF_POWER_ON;
	if (bIsResetBefore)
	{
		NAVIBOARD_RESET_ON;
	}

	NAVI_POWER_ON;
	
	memset(&ACCInfo,0,sizeof(ACC_INFO));
}

